ItemType Creation Unified + Frontend Migration + HTTP Path Fix Record
Date: 2026-07-09 (Continued)
Owner: AI Assistant (tuan_ workspace)
Background
The previous round completed 'Convergence of 3 create entry points to unified-create.js handleCreate' + real database persistence for 6 business types (Project/Product/Part/Vendor/Customer/ECN).
Goals for This Round:
- Make ItemType creation (including Property + RelationshipType) metadata-driven, supporting self-referential relationship backfilling.
- Migrate the frontend ItemTypeManagement.vue business page from the old useCreate.js to the unified entry point /api/unified/create.
- Fix the root cause of ItemType creation failure related to the actual HTTP path (the path used after frontend migration).
Completed Modifications
1. Backend handleCreate Metadata-Driven Enhancement (unified-create.js)
- Added isRelationshipItemType(): Determines based on the meta's is_relationship flag, causing relationship-type Items like Property/RelationshipType to be directly inlined, not independently added (complying with SCSAI unified object model constraints).
- Step 2 added CORE_FIELDS whitelist (name/keyed_name/description/classification/label/comments), ensuring SCSAI core system fields are not filtered out by filterAndSanitize.
- Added i18n value normalization: local meta stores multilingual fields as JSON strings ({"#text":"table","_lang":"en"}), extracts #text as the actual value after all default values are populated, to avoid illegal attribute values.
- Step 7 createRelationshipsRecursive: relational Item inline + self‑referencing related_id backfill parentId (when target type == parent type and id is empty).
2. Frontend ItemTypeManagement.vue migration
- Remove import { useCreate }, add local wrapper createViaUseCreate(), POST /api/unified/create (payload shape consistent with handleCreate contract: relationships array + item_properties.related_id).
- Retain createProgress reactive object for compatibility with template progress prompts.
- Only ItemTypeManagement.vue uses useCreate in the entire repository; migration has no side effects.
3. Root Cause Fix for HTTP Path ItemType Creation Failure (Core)
Direct handleCreate succeeded, HTTP path failed due to two root causes:
- (a) Missing name: The name was not registered in sciot_properties within the complete ItemType metadata, and filterAndSanitize filtered it out based on validNames → SCSAI PatternMismatchException (name is required). Fix: Use CORE_FIELDS whitelist as a fallback.
- (b) Invalid i18n object values: Default values for system fields like implementation_type/show_parameters_tab/structure_view in meta were stringified JSON {"#text":...} and were directly inserted into AML → SCSAI ArgumentOutOfRangeException. Fix: Perform i18n extraction after completing default values.
Verification Results (Real SCSAI scplm)
- 6 Capability Regression: create/repair/optimize/compare/generate/identify all show success=true (sources are unified_create / rule_engine / llm_router respectively).
- Object Class Creation (Direct handleCreate): success=true, rels=2 (1 Property + 1 self-referencing RelationshipType, with related_id correctly backfilled to the parent ItemType).
- Object class creation (HTTP /api/unified/create, i.e., the real path after frontend migration): success=true, id=20454A82..., rels=3 (2 Property + 1 self-referencing RelationshipType).
- Cleanup: Deleted temporary debugging files such as verify-class-rel.mjs / verify-http-class.mjs / probe-rt.mjs / qry-name.mjs / debug-create-fail.json, while retaining verify-capability-line.mjs.
Current Status
Unified convergence of object class creation and business class creation is complete. Frontend business pages have been migrated to the unified entry, and all HTTP real paths are green.
Pending confirmation (after user authorization):
- Delete redundant dead code / competing route branches: useCreate.js / capability-api.js.
- Route unification (ownership of /api/capability/* routes).
- Coverage of relationship-resolver for other title-type ItemTypes (ECN fixed, audit-noname discovered 32 title-type types).
BossAgents