Creating a New Data Product
CRITICAL OPERATIONAL RULE: You are an end-to-end deployment agent, not just a code generator. Your task is NOT complete until the Quality Gate (Build and Validate) has been executed. You MUST NOT stop after writing the files.
CRITICAL ISOLATION RULE (ZERO-TRUST FOR PLATFORM CODE): When creating or scaffolding a new data product, you MUST not modify or create files in the platform codebase (e.g., cortex-framework-core/src/common/, src/common/). Your edits must be strictly isolated to your custom data product directories (config/<namespace>/, src/data_modules/<namespace>/) and the main configuration file (config/config.yaml). Under no circumstances should you edit common platform utility functions, environment checkers, or services unless explicitly asked to do so by the user.
Step 1: Plan and Confirm
- Determine SAP Source Version (CRITICAL): You MUST explicitly ask and establish with the user whether the data product is designed for ECC, S/4HANA, or Both. Without this knowledge, proper implementation is impossible.
- SAP DDIC Metadata Retrieval (CRITICAL): You MUST use the
query-sap-ddicskill (via thepython3 external-skills/.agents/skills/query_sap_ddic/scripts/query_sap_ddic.pyscript) to query and retrieve ALL exhaustive details for each involved SAP table directly from the replicated SAP Data Dictionary (DDIC) metadata datasets in BigQuery. - Handle Custom SAP Fields (Z-fields, ZZ-fields, YY-fields): Verify if any custom SAP fields are required or exist in the raw replication schema. You MUST use the
query-sap-ddicskill to lookup their metadata structure, ABAP technical types, lengths, and check tables, and explicitly document their mapping in your implementation plan. - Handle Schema Differences Explicitly: Analyze the retrieved schema specs and explicitly identify and list any structural, field name, or data type differences between ECC and S/4HANA. Your implementation plan must explicitly handle these differences (e.g., using separate folders like
annotations/ecc/vsannotations/s4/, or conditional logic in the SQL definitions). - Identify and Validate Foundations: Check available data foundations in
src/data_modules/<namespace>/<source>/foundations/sap/andconfig/<namespace>/<source>/foundations/sap/. You MUST verify all required tables exist insrc/data_modules/<namespace>/<source>/foundations/sap/table_settings.default.yaml. If any tables are missing, explicitly document them in your implementation plan and define a sub-plan to manually scaffold them:- Developer Role (extending the codebase): Modify
table_settings.default.yamldirectly to add the missing tables. - End User/Deployer Role (configuring a target deployment): Do NOT modify
table_settings.default.yamldirectly. Instead, make a copy oftable_settings.default.yamlwith a custom name (e.g.,table_settings.yaml), add the missing tables to it, and reference this new file in the activeconfig.yamlusing thetableSettingsproperty. Ensure any new tables are inserted at the correct position to preserve alphabetical sorting bytableNamewithins4,ecc, andcommon. Fetch their schema via DDIC lookup skills, and generate theirannotations.yamlfiles in the foundation directory.
- Developer Role (extending the codebase): Modify
- Verify Custom Namespace: In accordance with the Cortex V7 Extensibility Guide, custom development MUST be placed in a custom namespace (e.g.,
custom,myorg) rather than the standardcortexnamespace to prevent conflicts and ensure clean upgrades.- If a custom namespace has not been specified, you MUST explicitly ask the user to provide a custom namespace name before proposing the plan.
- If the user explicitly instructs you to use the standard
cortexnamespace, you MUST warn them that modifying the standard namespace is against extensibility best practices and risks being overwritten during future upgrades. Obtain explicit confirmation before proceeding with thecortexnamespace.
- Propose Name: Suggest a descriptive name using snake_case.
- Legacy Model Reference: If legacy specifications or references are available, check if the data product models an existing or similar legacy data model.
- Research Field Mappings: Research the relevant field mappings between the data foundation and the new data product models, including the reasoning for each mapping, so the user can adjust them if needed.
- Evaluate Need for ABAP Source Code (CRITICAL): Depending on the user-provided requirements, your general understanding of SAP systems, the target version (ECC/S4HANA), and the business logic/modeling goals, evaluate if custom or standard ABAP program details are necessary to model the data product correctly (e.g. to replicate complex transaction statuses, calculations, or custom business rules). If required, you MUST explicitly ask the user for the relevant ABAP program names, specifications, or source code blocks.
- Propose Unit Tests Structure: Formulate the strategy for verifying the product via automated testing by proposing a dedicated Python unit test. Specify the target
pytestpaths and the relational assertions required to validate the compiled SQL joins, filters, and primary transformations. - Propose Plan: You MUST read the template file using your file reading tool at
assets/plan_template.md. The plan you propose MUST exactly follow the markdown headings and structure outlined in that file. Do not invent your own structure. - WAIT for user confirmation on the plan before writing any code.
Step 2: Scaffold Directories
Create the required target directories isolation framework, replacing <namespace>, <source>, and <type>:
src/data_modules/<namespace>/<source>/products/<type>/src/data_modules/<namespace>/<source>/products/<type>/annotations/(Addecc/ands4/subdirectories if there are differences between the source systems)src/data_modules/<namespace>/<source>/products/<type>/definitions/(Addecc/ands4/subdirectories if there are differences between the source systems)config/<namespace>/<source>/products/<type>/(Optional: only needed if creating custom config overrides)
Step 3: Create Files
CRITICAL: You MUST strictly follow the formatting and styling rules defined in style_guide.md.
1. manifest.yaml (src/data_modules/<namespace>/<source>/products/<type>/)
Use the template found at: manifest.yaml.md
2. Table Settings (e.g., table_settings.default.yaml or custom table_settings.yaml)
Depending on your role, choose the correct approach:
- Developer Role (building/extending data modules in the codebase):
- New Product (Scenario A): Create a new
table_settings.default.yamlcontaining the default configuration for the product. Use the template: table_settings.yaml.md - Adding Assets (Scenario B): Update the existing
table_settings.default.yamldirectly to add the new tables/views to the default distribution (for both product and foundation modules).
- New Product (Scenario A): Create a new
- End User/Deployer Role (configuring a target deployment or overriding settings):
- NEVER modify
table_settings.default.yamldirectly. Instead, make a copy namedtable_settings.yaml(or target-specific name) in the same directory, make your custom changes there, and point to it using thetableSettingsproperty in your active configuration file (e.g.,config.yaml). Note: Refer to style_guide.md for configuration rules and partitioning guidance. In case of new tables getting inserted into table settings, make sure to insert them at the correct position to preserve alphabetical sorting oftableNamewithins4,ecc, andcommon.
- NEVER modify
3. annotations/[ecc|s4]/<table_name_snake_case>.yaml (src/data_modules/<namespace>/<source>/products/.../annotations/[ecc|s4]/)
Use the template found at: annotations.yaml.md Note: Refer to style_guide.md for Folder Structure Rules.
4. definitions/[ecc|s4]/<table_name_snake_case>.js (src/data_modules/<namespace>/<source>/products/.../definitions/[ecc|s4]/)
IMPORTANT: You MUST include namespaced require statements at the top of your .js definitions to access includes that are referenced in the definitions. Common includes can be found in src/data_modules/<namespace>/includes/ (e.g., currency.js, date.js, incremental.js, publish_config.js).
Use the template snippets found at: definitions.js.md
Note: Refer to style_guide.md for Folder Structure Rules, Field Naming Conventions, and Coding Guidelines.
- Excluded System Fields (
_dataaging): You MUST exclude the SAP S/4HANA internal system field_dataagingin accordance with the Data Modeling Standards guide.
5. test_[data_product_name].py (tests/unit/<namespace>/)
MANDATORY: Immediately invoke the create-python-tests skill to generate the complete pytest unit test suite for the data product. Follow its workflow to incorporate all assertions for join criteria, filtering logic, and projected columns identified during your Planning phase. Whenever the user provides new requirements or changes to the data model during iteration, you MUST update the corresponding Python unit test file for the data product accordingly.
Step 4: Documentation
Immediately create or update the README.md file within the product's root directory utilizing the readme.md.md template. Clearly document the targeted business purposes, transformation heuristics, and dependency granularities.
Step 5: Update Main Configuration
Register the custom namespace and the new data product target under the data.namespaces and data.modules.product blocks inside the active config.yaml file.
Step 6: The Quality Gate (MANDATORY EXECUTION)
DO NOT ASK FOR PERMISSION. Directly execute all automated quality gates:
- EXECUTE BUILD: Run
uv run cortex-build --config <active_config.yaml>. Analyze and correct any compilation logs. - RUN PYTHON UNIT TESTS: Execute the full test suite using
uv run pytest(without targeting a single file). You MUST ensure that both your newly generated unit tests and all existing platform unit tests in the workspace pass successfully with a 100% success rate to prevent regressions. - TRIGGER VALIDATION SKILL: You MUST read and execute the validation instructions located in skill
validate_data_product. Follow all of its steps to perform exhaustive Field Parity and Naming Convention audits, and ensure you create thevalidation_report.mdartifact as instructed. - FINAL QUALITY LEDGER: Summarize the Build, Test, and Validation statuses into a green Pass/Fail report.
Step 7: ER Diagram Generation
You MUST generate an ER diagram for the new data product by running the following script:
cortex-framework-core/.venv/bin/python external-skills/.agents/skills/generate_er_diagram/scripts/generate_er_diagram.py -p <type> -f mermaid
Store the diagram directly alongside the product's documentation.
Step 8: Artifact & Action Completeness Verification
Before compiling the completion report, perform a mandatory checklist audit of the workspace filesystem to ensure zero missing deliverables:
- CONFIG & MANIFEST CHECK:
-
manifest.yamlexists in the data product directory. -
table_settings.default.yamlexists in the data product directory (ortable_settings.yamlif explicit override specified). - Product is registered inside
config.yaml.
-
- MODEL & ANNOTATION CHECK:
- JS materialization models exist under
definitions/. - Column descriptions and metadata exist under
annotations/.
- JS materialization models exist under
- DOCUMENTATION & DIAGRAM CHECK:
- Data product
README.mdis compiled using the standard template. - One or more ER diagram formats are present.
- Data product
- QUALITY GATES VERIFICATION:
-
uv run pytestexecuted with 100% success rate. -
validate-data-productexecuted with zero field parity errors.
-
If any check fails, resolve the missing action immediately before proceeding.
Step 9: Completion Report
Compile the final Data Product Creation Completion Report artifact and save it inside the standard brain artifacts directory using the completion_report_template.md template. Save this artifact with the exact filename completion_report.md. Sections and bullets inside the report MUST NOT BE REMOVED; if a section does not apply, mark it explicitly as "Not Applicable", "Missing", or "None".
Step 10: Deploy
Present the completed, validated product and its visual ER diagram to the user. REQUEST EXPLICIT APPROVAL before initiating live workspace deployment.