Quality Digital Employee Refactoring Plan (Based on PPS / SCSAI Real Object Class System)
Status: Design Document (v1, Pending Review). Basis: User-provided 'PPS Process System Complete Object Class System (C# Model + SCSAI ItemType)' dated 2026-08-01 + code verification.
Related: docs/Digital_Employee_Troubleshooting_Checklist.md ("Corrective (Architecture)" section), MEMORY.md "PPS/SCSAI Object Class System" section.
0. Background and Issues
The original Quality Digital Employee (QCC / CAPA / NCR / AUDIT / SPC / STAT / FMEA) master data path had no connection to PLM/SCSAI whatsoever:
- It read from fabricated local quality_* SQLite shadow tables (quality_inspections / quality_ncr / quality_capa / spc_control_limits / spc_data_points …).
- SCSAI was only used as a fallback in the pipeline identify step ("query only if scsaiClient exists"). Default overviews, overdue items, and KPIs all ran against local tables.
- Data Scribe DS-DATA-001 (data-clerk.js) only synchronized Part/Document/Vendor → SCSAI_sync_cache, not any quality-related data → quality_* tables have no SCSAI source.
User's assessment (original quote): "There is absolutely no interaction with the PLM server, no utilization of existing SCSAI capabilities... Although the tables for quality processes lack well-established relationships, they do exist as object classes prefixed with CASC." GL-5.1 also self-admitted: the previous engine's invention of storing quality tags, process_templates, etc., in raw_json for non-existent tables was an error.
Conclusion: The quality_* local table is an erroneous abstraction and must be deprecated. Quality staff should directly query the real ItemType + Relation combination tree from SCSAI and perform writes using the unified creation capability.
1. Architectural Principles (Mandatory)
- Data Source = Real ItemType from SCSAI; local storage of quality master data is eliminated.
- Any object can be created = Unified creation capability CapabilityRuntime.create (domain-agnostic): If the class does not exist, first _ensureItemType → smartCreateItemType (check for duplicates by name before creating class). If the class exists, resolveExistence checks for duplicate business objects (reuse if found, avoid duplicate creation). There should not and will not be a "quality-domain-exclusive creation employee".
- Relationships = RelationshipCapability / RelationshipResolver (used for both the PPS Relation table ParUID→SonUID via Type and the QS standard).
- Zero mock data, real validation: All queries/statistics/write-backs use the real SCSAI; honestly report success:false with missing data details if data is absent, never fabricate 0/green results.
- Unified scalar extraction: Property values returned by SCSAI are often objects ({_: "value"} / {keyed_name} / {#text}, see troubleshooting list line 29). All workers must use a shared _safeProperty(v) to extract scalars; direct String(v) conversion is prohibited (to avoid [object Object]).
2. Verified Real SCSAI Communication Layer API
Sources: server/utils/SCSAI-client.js, server/core/capability-runtime.js, server/core/relationship-capability.js, server/core/relationship-resolver.js.
2.1 Query
``js
const SCSAI = require('../../utils/SCSAI-client').getSharedClient(30000); // lazy, truthy even if not connected
const res = await SCSAI.sendAML(
select="item_number,state,created_on,due_date,root_cause" where="[state]='Open'" maxRecords="50">created_on desc ); // res = { success, items: [...], count, fault } // Some properties of each item may be objects → extract using _safeProperty ` `js const { CapabilityRuntime } = require('../../core/capability-runtime'); const rt = new CapabilityRuntime({/* applyAMLFn is injected by sharedClient.sendAML */}); const r = await rt.create('NCR', { item_number:'NCR-TEST-001', state:'Open', /* ... */ }); // Internally: resolveExistence checks for duplicates → _ensureItemType (creates class if it doesn't exist, checks for duplicate name before creation) → add AML ` `js // capability-runtime.js:1393 / 1419 const aml = + ${rt._escapeXml(value)}; await rt.applyAMLFn(aml); ` `js const rc = require('../../core/relationship-capability').getRelationshipCapability(); // Create relationship (with built-in duplicate check + mirror relationship) await rc.createRelation({ relation_type:'PPS_TechFile_Proc', source_id:techFileId, related_id:procId }); // Traverse relationships const rels = await rc.queryRelations(itemId, { relType:{name:'PPS_TechFile_Proc'} }); // → [{ id, source_id, related_id, related_name, sort_order, state }] ` RelationshipResolver provides resolveExistence (duplicate check), discoverRelations, buildLinkPlan/executePlan (automatic linking), which can be reused in "create/repair" steps. | Digital Worker | Real ItemType (Domain) | Main Read Fields | Write-back Action | |---|---|---|---| | DS-NCR-001 | NCR (QS, one of 21 categories) | item_number/state/created_on/due_date/root_cause/related_process | Overdue list, supplement root_cause (repair) | | DS-CAPA-001 | Quality Corrective Action (QS, i.e., CAPA) | item_number/state/created_on/due_date/effective_date | Overdue/unclosed list, progress status | | DS-AUDIT-001 | Audit (QS) | item_number/state/scheduled_date/completed_date | Overdue audit list | | DS-QCC-001 | CASC211_JG_Q_CONTROL_CARD + CASC211_JG_EXAMINE_ITEM (MES, 43 categories, corresponding to PPS_Report) | Quality control card entry/inspection item/status/overdue stagnation | Quality control card overview, stagnation warning, inspection item association | | DS-SPC-001 | Characteristic (QP_Module, process characteristic → SPC monitoring target) + CASC211_JG_EXAMINE_ITEM (Cpk candidate) | characteristic upper/lower limits/Cpk, inspection item measurement value | Cpk monitoring, low Cpk warning | | DS-STAT-001 | Cross-domain Aggregation: NCR + Quality Corrective Action + Audit + Characteristic (Cpk) | Multi-category Daily Window Statistics | KPI Dashboard (Real-time Calculation, No Cached Table Reads) | | DS-FMEA-001 | DFMEA / PFMEA (QP_Module, including FMEA sub-objects Action/Cause/Control/Effect/Failure Mode) | RPN = SEV × OCC × DET, high_rpn items | High RPN Alert, FMEA Action Tracking | Correcting previous misinterpretations (already documented in MEMORY.md): CAPA's actual class name = Quality Corrective Action; PFMEA belongs to QP_Module (parallel to DFMEA); CASC211_JG_* classes do exist (detecting 0 rows = class exists but has no data, not class non-existence, possibly in another instance). All internal SCSAI attribute names (e.g., date/status field names for NCR, Cpk field name for Characteristic) must be verified by read-only get on a real record before coding; speculation is prohibited. Each worker retains the existing pipeline/staff framework (runStaffOnce), only replacing the data source: local quality_* queries → SCSAI.sendAML/CapabilityRuntime; all statistical definitions switch to real-time aggregation on actual ItemTypes. Quality personnel need to obtain "process context" (part/process/characteristic), must combine along the real Relation table: ` TechFile(PPSSystem_TechFile) ─(PPS_TechFile_Proc)→ Proc(PPS_Proc, TypeID=PT) ─(PPS_Proc_Step)→ Step(PPS_Step, TypeID=ST) ─(PPS_Proc_Field)→ Field(PPS_Field, TypeID=FT) ─(PPS_TechFile_Data)→ TechData(PPS_TechData, ColumnID=CL) → Column(CL Code Definition) ─(PPS_TechFile_Report)→ Report(PPS_Report, RT) ← CASC211_JG_Q_CONTROL_CARD corresponds to this ─(PPS_TechFile_Resource)→ Resource ` Format: → Real attribute name list + sample values (desensitized) + available Relation type names. Placeholder: [To be obtained via P0 read-only get detection].2.2 Create (Unified Capability)
2.3 Edit / Write Back
2.4 Relationships (PPS Relation / QS Relationships)
3. Digital Worker → Real ItemType Mapping Table
4. Per-Employee Design
4.1 DS-NCR-001 (NCR, simplest, scplm confirmed data exists NCR-0032 → serves as pilot template)
4.2 DS-CAPA-001 (Quality Corrective Action, i.e., CAPA)
4.3 DS-AUDIT-001 (Audit)
4.4 DS-QCC-001 (CASC211_JG_Q_CONTROL_CARD + EXAMINE_ITEM)
4.5 DS-SPC-001 (Characteristic + EXAMINE_ITEM Cpk)
4.6 DS-STAT-001 (Cross-domain Real-time Aggregation)
4.7 DS-FMEA-001 (DFMEA / PFMEA)
5. PPS Combination Tree (Relation.Type) Traversal
6. Migration strategy for deprecated quality_* local tables
7. Verification criteria (real validation, zero simulation)
8. Implementation Steps (Phased)
Phase Content Exit Criteria P0 Field Exploration Run read-only get for each target ItemType, confirm attribute names + Relation type names, complete appendix of this plan Appendix complete, no placeholder [To probe] P1 NCR Pilot Rewrite DS-NCR-001 full SCSAI direct connection + unified creation + fix + comparison; real verification End-to-end 6 capabilities validated, assertions hit real values P2 Rollout QS Domain CAPA / AUDIT isomorphic rewrite (reusing NCR pattern) Three employees directly connected and passed P3 Machining QC + SPC QCC (CASC211_JG_* + PPS combination tree traversal) / SPC (Characteristic Cpk) QC cards/characteristics read correctly, Cpk alerts function properly P4 Aggregation + FMEA STAT cross-domain real-time aggregation, FMEA (DFMEA/PFMEA) 10 KPIs calculated in real-time, alerts self-consistent; FMEA with high RPN does not crash P5 Wrap-up Deprecate quality_* main path, clean seed scripts, update troubleshooting checklist/knowledge base All 7 employees real verification passed, no local shadow table dependencies 9. Risks and Open Questions
10. Appendix (P0 exploration output, to be gradually completed)
BossAgents